<template>
	<view v-if="show" class="position-fixed input-bg-color rounded flex justify-center shadow
	align-center vivify popIn main" :style="diyPosition"
	:class="animation"
	>
		<view class="iconfont icon-huidaodingbu icon" @tap="backTop"></view>
	</view>
</template>

<script>
	export default{
		// pageScrollStatus
		created(){
			uni.$on("showBackTop",status=>{
				this.show = status
			})
		},
		destroyed(){
			uni.$off("showBackTop")
		},
		props:{
			right:{
				type:String,
				default:"50rpx"
			},
			bottom:{
				type:String,
				default:"50rpx"
			}
		},
		data(){
			return {
				show:false
			}
		},
		computed: {
			animation(){
				return this.show?"popIn":"popOut"
			},
			diyPosition(){
				return {
					right:this.right,
					bottom:this.bottom
				}
			}  
		},

		methods:{
			backTop(){
				uni.pageScrollTo({
					scrollTop: 0 
				})
			}
		}
	}
</script>

<style scoped>
	.main{
		width: 90rpx; 
		height: 90rpx; 

	}
	.icon{
		font-size: 50rpx;
	}
</style>